<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .div3{
            width: 100px;
            height: 5000px;
            overflow: scroll;
            border: 1px solid #000;
        }
        .div2{
            width: 50px;
            height: 50px;
            font-size: 50px;
            border:1px solid #000;
            text-align: center;
            user-select: none;
            position: fixed;
            bottom: 100px;
            right: 100px;
            display: none;
        }
    </style>
</head>
<body>
    <div class="div2">^</div>
    <div class="div3">1238888888888</div>
    <script>
         var div2;
       var bool=false;
        init();
        function init(){
            div2=document.querySelector(".div2");
            div2.addEventListener("click",clickhandler);
            document.addEventListener("scroll",scollHandler);
            setInterval(animation,16);
        }

        function scollHandler(e){
            if(document.documentElement.scrollTop>document.documentElement.clientHeight){
                div2.style.display="block";
            }else{
                div2.style.display="none";
            }
        }

        function clickhandler(e){
            bool=true;
        }

        function animation(){
            if(!bool) return;
            document.documentElement.scrollTop-=500;
            bool=document.documentElement.scrollTop!==0;
        }
    </script>
</body>
</html>